package com.ayuku.commons.ui.users;

import java.util.logging.Logger;

import org.eclipse.nebula.widgets.tablecombo.TableCombo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wb.swt.SWTResourceManager;

import com.ayuku.commons.Util;

/**
 * 
 * @author putu kusuma <putukn@gmail.com>
 * 
 */
public class CompUser extends org.eclipse.swt.widgets.Composite {

	protected Text txtPassword;
	protected Text txtNamaLengkap;
	protected Text txtEmail;
	protected Text txtUsername;
	protected TableCombo cmbGroup;
	private static Logger LOG = Logger.getLogger(CompUser.class.getName());

	public CompUser(final org.eclipse.swt.widgets.Composite parent,
			final int style) {
		super(parent, style);
		initGUI();
	}

	private void initGUI() {
		try {

			this.setBackground(SWTResourceManager.getColor(215, 213, 253));
			setLayout(new GridLayout(2, false));

			final Label label1 = new Label(this, SWT.NONE);
			label1.setText("Username:");
			label1.setAlignment(SWT.RIGHT);

			label1.setBackground(SWTResourceManager.getColor(215, 213, 253));
			txtUsername = new Text(this, SWT.BORDER);
			txtUsername.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
					false, 1, 1));
			txtUsername.setTextLimit(20);

			final Label label2 = new Label(this, SWT.NONE);
			label2.setText("Password:");
			label2.setAlignment(SWT.RIGHT);

			label2.setBackground(SWTResourceManager.getColor(215, 213, 253));

			txtPassword = new Text(this, SWT.PASSWORD | SWT.BORDER);
			txtPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
					false, 1, 1));
			txtPassword.setTextLimit(20);

			final Label label6 = new Label(this, SWT.NONE);
			label6.setText("Nama Lengkap: ");
			label6.setAlignment(SWT.RIGHT);

			label6.setBackground(SWTResourceManager.getColor(215, 213, 253));

			txtNamaLengkap = new Text(this, SWT.BORDER);
			txtNamaLengkap.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
					true, false, 1, 1));
			txtNamaLengkap.setTextLimit(50);

			final Label label4 = new Label(this, SWT.NONE);
			label4.setText("Email:");
			label4.setAlignment(SWT.RIGHT);

			label4.setBackground(SWTResourceManager.getColor(215, 213, 253));
			txtEmail = new Text(this, SWT.BORDER);
			txtEmail.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
					false, 1, 1));
			txtEmail.setTextLimit(30);

			final Label label3 = new Label(this, SWT.NONE);
			label3.setText("Group:");
			label3.setAlignment(SWT.RIGHT);

			label3.setBackground(SWTResourceManager.getColor(215, 213, 253));

			cmbGroup = new TableCombo(this, SWT.BORDER | SWT.READ_ONLY);
			cmbGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
					false, 1, 1));

			this.layout();

		} catch (Exception e) {
			e.printStackTrace();
			LOG.info(e.getMessage());
			Util.showMsgBox("Gagal load: " + e.getMessage(), 1, getShell());
		}
	}
}
